package com.hc.server.actions;

import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.hc.server.Error;
import com.hc.server.IAction;
import com.hc.server.Request;
import com.hc.server.Response;

/**
 * 查询旅游线路
 * @author xujh
 *
 */
public class QUERY_TRAVELS implements IAction{

	private static final String CITY = "CITY";
	private static final String CHECKIN_DATE = "CHECKIN_DATE";
	private static final String KEY_WORD = "KEY";
	private static final String SORT = "SORT";

	private static final String NAME = "NAME";
	private static final String SPRICE = "SPRICE";
	private static final String MPRICE = "MPRICE";
	private static final String DAYS = "DAYS";//行程天数
	private static final String FEE = "FEE";//费用包含
	private static final String USEAGE = "USEAGE";//如何使用
	private static final String NOTES = "NOTES";//购买须知
	private static final String FEATURES = "FEATURES";//特色介绍
	private static final String DES = "DES";//具体行程安排
	private static final String STOCK = "STOCK";//库存
	
	private static final String TRAVELS = "TRAVELS";
	private static final String TOTAL_RESULT = "TOTAL_RESULT";
	
	@Override
	public void execute(Request req, Response resp) {
		//1.取请求参数
		String city;
		
		try {
			city = req.getStrArg(CITY);
		} catch (JSONException e) {
			resp.setErrResp(Error.INVALID_ARGS_ERR_CD, Error.INVALID_ARGS_ERR_MSG);
			return;
		}
		String checkInDate = req.optStrArg(CHECKIN_DATE);
		int orderBy = req.optIntArg(SORT);
		String keyWord = req.optStrArg(KEY_WORD);
		//2.查询结果
		
		//3.组织返回结果
		JSONArray travels = new JSONArray();
		JSONObject travel = new JSONObject();
//		travel.put(NAME, value);
//		travel.put(DAYS, value);
//		travel.put(MPRICE, value);
//		travel.put(SPRICE, value);
//		travel.put(FEE, value);
//		travel.put(USEAGE, value);
//		travel.put(NOTES, value);
//		travel.put(FEATURES, value);
//		travel.put(DES, value);
//		travel.put(STOCK, value);
		travels.put(travel);
		
		resp.appendRespContent(TRAVELS, travels);
//		resp.appendRespContent(TOTAL_RESULT, value);
	}

}
